import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Scanner;
import java.util.Set;
import java.util.Vector;


public class SDRparse {

	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args)
	{	
		/*Person steve1 = new Person("Steve", 23);
		Person steve2 = new Person("Steve", 25);
		Person steve3 = new Person("Steve", 23);
		Person steve4 = new Person("Steve", 25);
		ArrayList<Person> p1 = new ArrayList<Person>();
		ArrayList<Person> p2= new ArrayList<Person>();
		p1.add(steve1);
		p1.add(steve2);
		p2.add(steve4);
		p2.add(steve3);
		System.out.println(p1.containsAll(p2));
		System.exit(0);*/
		
		UnaryRuleTranslator u = new UnaryRuleTranslator();
		StevesStringDivider div = new StevesStringDivider(' ');
		Scanner in = new Scanner(System.in);

		String input = "Rudolph:np_1/n_1 Agnew:n_2 smokes:s_3\\np_4/np_5 a:np_6/n_6 pipe:n_8";
		
		String[] data = div.divide(input);
		ArrayList<Sign> inputDivided = new ArrayList<Sign>();
		for(int a = 0; a < data.length; a++)
		{
			Sign s = new Sign(data[a],a);
			inputDivided.add(s);
		}
		
		SDRparser parser = new SDRparser(u);
		Chart theChart = parser.parse(inputDivided);
		HashSet<Sign> result = theChart.getResults();
		Iterator i = result.iterator();
		System.out.println("Results:");
		
		ArrayList<SignSorter> listOfResults = new ArrayList<SignSorter>();
		while(i.hasNext())
		{
			Sign spotlight = (Sign) i.next();
			listOfResults.add(new SignSorter(spotlight));
		}
		Collections.sort(listOfResults);
		Iterator j = listOfResults.iterator();
		while(j.hasNext())
		{
			SignSorter spotlight2 = (SignSorter) j.next();
			Sign spotlight = spotlight2.getSign();
			if(spotlight.getSuperDuperTag().toStringForComp().equals("s"))
			{
				System.out.println(spotlight.toStringReadable() + " (" + spotlight2.getVal() + ")");
				System.out.println(spotlight.pargFileToParg());
				System.out.println(spotlight.printDennisDependencies());
			}
		}
		//System.out.println(theChart.toString());
	}

}
